package io.github.wjehovah.yyn.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;

import java.util.List;

import io.github.wjehovah.yyn.App;
import io.github.wjehovah.yyn.R;
import io.github.wjehovah.yyn.bean.MineBean;

/**
 * Created by lcy on 2015/8/5.
 */
public class MineGrideViewAdaper extends BaseAdapter{
    private final LayoutInflater mLayoutInflater;
    private List<MineBean.Mine> data;
    private Context context;
    public MineGrideViewAdaper(List<MineBean.Mine> data,Context context) {
        this.data = data;
        mLayoutInflater = LayoutInflater.from(context);
        this.context=context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        {
            ViewHolder holder = null;
            if (convertView == null) {
                holder = new ViewHolder();
                convertView = mLayoutInflater.inflate(R.layout.mine_item, null, false);
                convertView.setTag(position);//
                holder.imageView = (ImageView) convertView.findViewById(R.id.iv_mine_item_image);
                holder.content = (TextView) convertView.findViewById(R.id.iv_mine_item_content);
                //        设置监听
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            MineBean.Mine mine = data.get(position);
            BitmapUtils bitmapUtils = new BitmapUtils(App.getContext());
            bitmapUtils.display(holder.imageView, mine.icon);//用户名头像；
            Log.e("LCY","用户名头像"+ mine.icon);
            holder.content.setText(mine.name);//内容:神帖
            return convertView;
        }
    }
    static class ViewHolder {
        ImageView imageView;
        TextView content;
    }
}
